#!/bin/bash
# echo the call so we can see what's going on
echo "$0 $1 $2 $3 $4 $5 $6"

# Check syntax
if [ "$1" = "" ]; then
	echo "$0 called without number of histogram for which background should be changed!"
	exit 0
fi

if [ "$2" = "" ]; then
	echo "$0 called without background function to be used!"
	exit 0
fi

if [ "$3" = "" ]; then
	echo "$0 called without number of coefficients to be used!"
	exit 0
fi

# Add the phase
echo "k l o b" > temp.txt
echo "h $1" >> temp.txt
echo "c $2 $3 /" >> temp.txt
echo "x" >> temp.txt
echo "x" >> temp.txt
echo "x" >> temp.txt
echo "x" >> temp.txt

expedt `cat GSAS_EXP` < temp.txt > out.txt

# Test the EXP file
echo "Changed background for histogram $1 to function number $2 and $3 coefficients.\newline" >> temp.tex
